<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>">

		<title>广东科学技术职业学院考生报到系统>>>>招就处</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">

		<link href="css/newindex.css" rel="stylesheet" type="text/css" />
		<link href="css/pagecss.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" href="css/jquery-ui-1.8.5.custom.css"
			type="text/css" />
		<script src="js/jquery-1.5.js" language="javascript">
</script>
		<script src="js/finance.js" language="javascript">
</script>
		<script src="js/jquery-ui-1.8.5.custom.min.js" language="javascript">
</script>
		<script src="js/table.js" language="javascript">
</script>
		<script src="js/pageInfo.js" type="text/javascript">
</script>
		<script src="js/newpublic.js" language="javascript">
</script>
		<script src="js/jquery.bgiframe.js" type="text/javascript">
</script>
		<script language="javascript">
var collegeId;  //学院ID
var professionId;  //专业ID
var clazz;  //班级
var subjectId;  //科目ID
var areaId;  //地区ID
var param = {};  //传到action的属性
var flag;
$(function() {
	initData();
	$("#content").draggable({cancel:".contable"});
	flag = 1;
	$("input[name='radio'][value=1]").attr("checked",true);  
	//隐藏结果div
	$("#t1").hide();
	//级联   学院改变时变动其它下拉框
	$("#collegeList").change(function() {
		collegeId = $("#collegeList").val();
		if(collegeId == "all") {
			$("#professionList").empty();
			$("#professionList").append("<option value='all'>全部</option>");
		} else {
			$.post("json/studentQueryAction!initProfession", {'collegeId' : collegeId},
				function(data) {
				professionList = eval("(" + data.professionList_Json + ")");
				$("#professionList").empty();
				$("#professionList").append("<option value='all'>全部</option>");
				for(var i=0; i<professionList.length; i++) {
					$("#professionList").append("<option value='" + professionList[i].professionId + "'>" + professionList[i].professionName + "</option>");
				}
			})
		}
		$("#clazzList").empty();
		$("#clazzList").append("<option value='all'>全部</option>");
	})
	
	//级联   专业改变时变动其它下拉框
	$("#professionList").change(function() {
		professionId = $("#professionList").val();
		if(professionId == "all") {
			$("#clazzList").empty();
			$("#clazzList").append("<option value='all'>全部</option>");
		} else {
			$.post("json/studentQueryAction!initClazz", {'professionId' : professionId},
				function(data) {
				$("#clazzList").empty();
				$("#clazzList").append("<option value='all'>全部</option>");
				for(var i=1; i<=data.clazzCount; i++) {
					$("#clazzList").append("<option value='" + i + "'>" + i + "</option>");
				}
			})
		}
	})
	
	//查询
	$("#search").click(function() {
		//构建所有属性
		collegeId = $("#collegeList").val();
		professionId = $("#professionList").val();
		clazz = $("#clazzList").val();
		subjectId = $("#subjectList").val();
		areaId = $("#areaList").val();
		param={};
		if(collegeId != "all")
			param.collegeId=collegeId ;
		if(professionId != "all") 
			param.professionId = professionId;
		if(clazz != "all") 
			param.clazz = clazz;
		if(subjectId != "all") 
			param.subjectId = subjectId;
		if(areaId != "all") 
			param.areaId = areaId;
		param.date=new Date();
		
		var index = <s:property value="pageInfo.pageIndex"/>;
		var size = <s:property value="pageInfo.pageSize"/>;
		
		//post数据, 带分页
		ajaxSubmit(index, size);
	})
	
	//点击精确查询弹出查询窗口
	$("#singleSearch").click(function () {
		$("#singleStudent").show()
			//显示 div
		$("#examCode").val("");	
		$("#idCode").val("");
		$("#studentName").val("");
		
		$("#singleStudent").dialog({
				modal: true,
				resizable:false,
				width:600,
				height:300
		})
		
		$("table#stu_info tr").remove();  //把之前数据删除
	})
	
	//精确查询中的查询事件
	$("#studentSearch").click(function() {
		var examCode = $("#examCode").val();  //准考证号
		var idCode = $("#idCode").val();  //身份证号
		var studentName = $("#studentName").val();  //学生姓名
		var values = {};
		//各个验证
		var regExamCode = /^\d{5,}/;
		var regIdCode = /^.{6,}/;
		var regStudentName = /.+/;
		if(regExamCode.test(examCode) || regIdCode.test(idCode) || regStudentName.test(studentName)) {
			if(regExamCode.test(examCode))
				values.examCode = examCode;
			if(regIdCode.test(idCode))
				values.idCode = idCode;
			if(regStudentName.test(studentName)) 
				values.studentName = studentName;
			$.post("json/studentQueryAction!queryStudentByCondition", values, 
			function(data) {
			fillStudent(data.studentInfo_Json);  //填充服务器端返回的数据
		})	
		} else {
			alert("输入格式错误, 请输入任意符合的条件进行查询!\n注:\n准考证号:输入准考证号末5位或以上, 必须为整数!"+
			"\n身份证号:身份证号末6位或以上!\n学生姓名:不能为空!");
		}
	})
})

//填充精确查询的数据
function fillStudent(data) {
	data = eval("(" + data + ")");
	$("table#stu_info tr").remove();  //把之前数据删除
	if(data == "") {
		$("#t1").hide();
		alert("没有找到相应记录!");
	} else {
		for(var a in data) {
			var tr = "";
			if(a != 0)
				tr += '<tr><td colspan="4"><hr></td></tr>';
			tr += '<tr><td>姓名:</td>	<td align="left">' + data[a].studentName + '</td><td>是否报道</td>' +
			'<td>' + (data[a].isRegister?'是':'否') + '</td>	</tr><tr><td>准考证号:</td><td>' + data[a].examCode + '</td>' +
			'<td>身份证号:</td><td>' + data[a].idCode + '</td></tr><tr><td>学院:</td><td>' + data[a].college + '</td>' +
			'<td>班级:</td><td>' + (data[a].profession+data[a].clazz)+ '班</td></tr><tr><td>性别:</td><td>' + (data[a].sex?"男":"女") + '</td>' +
			'<td>科目:</td><td>' + data[a].subject + '</td></tr>	<tr><td>地区:</td><td>' + data[a].area + '</td>' +
			'<td>欠费:</td><td>' + data[a].unpaidFees + '</td></tr><tr><td>宿舍：</td><td>'+(data[a].dormNumber?data[a].dormNumber:"未分配")+'</td><td></td><td></td></tr>';
			$("#stu_info").append(tr);
		}
	}
}

//初始化所有下拉窗口数据
function initData() {
	$.post("json/studentQueryAction!initInfo", function(data) {
		var collegeList = eval("(" + data.collegeList_Json + ")");
		$("#collegeList").empty();
		$("#collegeList").append("<option value='all'>全部</option>");
		for(var i=0; i<collegeList.length; i++) {
			$("#collegeList").append("<option value='" + collegeList[i].collegeId + "'>" + collegeList[i].collegeName + "</option>");
		}
		var subjectList = eval("(" + data.subjectList_Json + ")");
		$("#subjectList").empty();
		$("#subjectList").append("<option value='all'>全部</option>");
		for(var i=0; i<subjectList.length; i++) {
			$("#subjectList").append("<option value='" + subjectList[i].subjectId + "'>" + subjectList[i].subjectName + "</option>");
		}
		var areaList = eval("(" + data.areaList_Json + ")");
		$("#areaList").empty();
		$("#areaList").append("<option value='all'>全部</option>");
		for(var i=0; i<areaList.length; i++) {
			$("#areaList").append("<option value='" + areaList[i].areaId + "'>" + areaList[i].areaName + "</option>");
		}
	})
}

//多个查询的数据展示
function showData(data) {
	data = eval("(" + data + ")");
	if(data == '') {
		$("#t1").hide();
		alert("没有找到相应记录!");
		$("table#studentInfo tr:gt(0)").remove();
		var tr='<tr><td height="21" align="center">&nbsp;</td><td align="center">&nbsp;' + 
					'</td><td align="center">&nbsp;</td><td align="center">&nbsp;' + 
					'</td><td align="center">&nbsp;</td><td align="center">&nbsp;' +
					'</td><td align="center">&nbsp;</td><td align="center">&nbsp;' + 
					'</td><td align="center">&nbsp;</td><td align="center">&nbsp;</td></tr>';
			$("#studentInfo").append(tr);
	} else {
		$("table#studentInfo tr:gt(0)").remove();
		$("#t1").show();
		for(var a in data) {
			var unpaidFees=data[a].unpaidFees>0?"<font color='red'>"+data[a].unpaidFees+"</font>":data[a].unpaidFees
			var tr='<tr><td height="21" align="center">' + data[a].studentName + '</td><td height="21" align="center">' + (data[a].sex?"男":"女") + '</td><td align="center">' + data[a].examCode + 
					'</td><td align="center">' + data[a].idCode + '</td><td align="center">' + data[a].college + 
					'</td><td align="center">' + data[a].profession + '</td><td align="center">' + data[a].clazz + 
					'</td><td align="center">' + data[a].subject + '</td><td align="center">' + data[a].area +
					'</td><td align="center">' + data[a].feePayable + '</td><td align="center">' + unpaidFees + '</td><td align="center">' + (data[a].dormNumber?data[a].dormNumber:"未分配") + '</td><td align="center">' + 
					(data[a].isRegister ? '是' : '否') + '</td></tr>';
			$("#studentInfo").append(tr);
			$("table#studentInfo tr:gt(0):odd").css('background','#deefff'); 
			$("table#studentInfo tr:gt(0):even").css('background','#fff');		
		}
	}
}

//分页提交
function ajaxSubmit(index, size) {
	param.pageIndex=index;
	param.size=size;
	$.post("json/studentQueryAction!queryStudent", param, function(data) {
		var page = eval('(' + data.pageJson + ')');
		initPage(page.totalPage, page.pageIndex, page.pageSize, page.totalRec);
		showData(data.studentInfo_Json);
	});
}

function setFlag(s){
	flag = s;
}
function exportDormExcel() {
	
		var url = 'exportStudentQueryExcel.action?flag=' +flag;
		if(param.collegeId != null){
			url += '&collegeId=' + param.collegeId;
		}
		if(param.clazz != null){
			url += '&clazz=' + param.clazz;
		}
		if(param.subjectId != null){
			url += '&subjectId=' + param.subjectId;
		}
		if(param.areaId != null){
			url += '&areaId=' + param.areaId;
		}
		if(param.professionId != null){
			url += '&professionId=' + param.professionId;
		}
		if(param.pageIndex != null)
				url += '&pageIndex=' + param.pageIndex;
		if(param.size != null)
			url += '&size=' + param.size; 
		
		$("#export_excel_form").attr("action",url).submit();
	}
</script>

	</head>
	<body onload="fixPNGAll()">
		<div id="bg">
			<div id="bodydiv">
				<div id="bodytitle">
					招就处
					<div>
						<a href="logoutAction" style="color: #F00;">退出</a>
					</div>
				</div>

				<div id="menudiv">
					<jsp:include page="entrance_header.jsp"></jsp:include>
				</div>
				<div id="content">
					<!--当前位置CSS-->
					<div class="top">
						<div class="topleft">
							<div class="dan">
								<div>
									当前位置>招就处>学生信息
								</div>
							</div>
							<div class="F5">
								<img src="newimages/F5.png" />
							</div>
						</div>
						<div class="topright">
							<div class="toprightmin"></div>
							<div class="toprightmax"></div>
							<div class="toprightclose" onclick="if(confirm('是否确定退出！')){location.replace('loginoutAction')}" title="点击退出"></div>
						</div>
					</div>
					<!---->
					<!--内容-->
					<div class="condiv">
						<div class="submenu">

						</div>
						<div class="contable">
							<!--******************************-->
							<div class="title">
								学生概况
							</div>
							<table width="100%" border="0" cellspacing="5" cellpadding="0">
								<tr>
									<td align="right">
										学院：
									</td>
									<td>
										<select id="collegeList">
											<option>
												--请选择学院--
											</option>
											<option value="0">
												计算机学院
											</option>
											<option value="1">
												外国语学院
											</option>
											<option value="2">
												建工学院
											</option>
											<option>
												经管学院
											</option>
											<option>
												人文学院
											</option>
											<option>
												机电学院
											</option>
											<option>
												体教部
											</option>
											<option>
												广州学院
											</option>
										</select>
									</td>
									<td align="right">
										专业：
									</td>
									<td>
										<select id="professionList">
											<option value="all">
												全部
											</option>
										</select>
									</td>
									<td align="right">
										班级：
									</td>
									<td>
										<select id="clazzList">
											<option value="all">
												全部
											</option>
										</select>
									</td>

									<td align="right">
										科目：
									</td>
									<td>
										<select id="subjectList">
											<option>
												----全部----
											</option>
											<option>
												普高（文）
											</option>
											<option>
												普高（理）
											</option>
											<option>
												中职
											</option>
											<option>
												自主招生
											</option>
											<option>
												独立招生
											</option>
											<option>
												艺术
											</option>
										</select>
									</td>
									<td align="right">
										地区：
									</td>
									<td>
										<select id="areaList">
											<option selected="selected">
												全部
											</option>
											<option>
												广州
											</option>
											<option>
												佛山
											</option>
											<option>
												珠海
											</option>
											<option>
												汕头
											</option>
											<option>
												潮州
											</option>
										</select>
									</td>
									<td>
										<input type="button" id="search" value="查询" />
										&nbsp;&nbsp;
										<input type="button" id="singleSearch" value="精确查询" />
									</td>
								</tr>

							</table>





							<div id="t1">
								<table width="95%" border="0" align="center" cellpadding="0"
									cellspacing="1"
									style="margin-top: 30px; border: 1px solid #5cb0ff;" class="t1"
									id="studentInfo">
									<tr>
										<th align="center">
											姓名
										</th>
										<th align="center">
											性别
										</th>
										<th align="center">
											准考证
										</th>
										<th align="center">
											身份证
										</th>
										<th align="center">
											学院
										</th>
										<th align="center">
											专业
										</th>
										<th align="center">
											班级
										</th>
										<th align="center">
											科目
										</th>
										<th align="center">
											地区
										</th>
										<th align="center">
											学费
										</th>
										<th align="center">
											欠费
										</th>
										<th align="center">
											宿舍号
										</th>
										<th align="center">
											是否报道
										</th>
									</tr>

								</table>

								<!--上一页，下一页 开始-->
								<table width="100%" class="pagecss">
									<tr>
										<td align="left">
											<span id="AllPage">共几页/几条</span>
											<span id="setupNum">显示每页记录条数</span>
											<select id="setSize"
												onchange="ajaxChangeCount(this.options[this.options.selectedIndex].value)">
											</select>
										</td>
										<td align="right">
											<span id="Flexigrid_Bar"><a href="">上5页</a><span
												class="dan">1</span><a href="">2</a><a href="">3</a><a
												href="">下5页</a> </span>
											<span id="checkPage"><input type="text"
													style="width: 20px;" /> &nbsp;页<a href="">GO</a> </span>
										</td>
									</tr>
								</table>
								<!--上一页，下一页 结束-->

								<form action="" method="post" id="export_excel_form" >
											<table width="100%" border="0" cellspacing="5" cellpadding="0">
											<tr>
												<td width="91%" align="right">
													<input type="radio" name="radio" id="radio" value="1" onclick="setFlag(1)"
														checked="checked" />
													本页
												</td>
												<td width="9%" rowspan="2">
													<input type="button" value="导出" onclick="exportDormExcel()"/>
												</td>
											</tr>
											<tr>
												<td align="right">
													<input type="radio" name="radio" id="radio" value="2" onclick="setFlag(0)"/>
													全部
												</td>
											</tr>
										</table>
									</form>
							</div>

							<div id="singleStudent" style="display: none;" title="学生信息查询">
								<table>
									<tr>
										<td>
											准考证号:
											<input type="text" id="examCode" />
										</td>
										<td>
											身份证号:
											<input type="text" id="idCode" />
										</td>
										<td>
											姓名:
											<input type="text" id="studentName" />
										</td>
										<td>
											<input type="button" id="studentSearch" value="查找" />
										</td>
									</tr>
								</table>
								学生信息:
								<br />

							<div style="overflow: auto; height:150px">
								<table style="width: 80%" id="stu_info">
									<tr>
										<td>
											姓名:
										</td>
										<td align="left"></td>
										<td>
											是否报道
										</td>
										<td>
											是
										</td>
									</tr>
									<tr>
										<td>
											准考证号:
										</td>
										<td>
											12312345
										</td>
										<td>
											身份证号:
										</td>
										<td>
											123456789012345678
										</td>
									</tr>
									<tr>
										<td>
											学院:
										</td>
										<td>
											计算机工程技术
										</td>
										<td>
											专业:
										</td>
										<td>
											计算机多媒体
										</td>
									</tr>
									<tr>
										<td>
											班级:
										</td>
										<td>
											多媒体1
										</td>
										<td>
											科目:
										</td>
										<td>
											普高(理科)
										</td>
									</tr>
									<tr>
										<td>
											地区:
										</td>
										<td>
											珠海市
										</td>
										<td>
											欠费:
										</td>
										<td>
											1231
										</td>
									</tr>
								</table>
							</div>
							</div>

							<!-------**********************************-------->
							<!----------------------------------------------->
						</div>
					</div>
					<!---->
					<!---->
					<div class="condiv"
						style="width: 997px; position: relative; height: 20px; min-height: 20px; text-align: center;">
						<a href="computer/computer.html" target="_blank">计算机学院程序员之家</a>
					</div>
					<!---->

					<!--低部-->
					<div class="bottom">
						&nbsp;
					</div>
					<!---->
				</div>
			</div>
		</div>
	</body>
</html>

